package zhang.lao.console.controller.wn.report;/**
 * Created by zhangqin on 2017/8/30.
 */

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import zhang.lao.service.console.ReportService;
import zhang.lao.pojo.console.ConsoleContext;
import zhang.lao.pojo.console.report.AreaReportResp;
import zhang.lao.pojo.console.resp.HttpResult;
import zhang.lao.pojo.console.resp.HttpResultUtil;

/**
 * 报表
 *
 * @author
 * @create 2017-08-30 9:30
 **/
@Controller
public class AutoMachineAreaReport {


    @Autowired
    private ReportService reportService;
    @RequestMapping("/console/report/automachine/area")
    public String getAutoAreaReport(ModelMap modelMap){
        return "console/report/auto_machine_area_report";
    }
    @RequestMapping("/console/report/automachine")
    public String getAutoautomachineReport(ModelMap modelMap){
        return "console/report/auto_machine_active";
    }
    @RequestMapping("/console/report/automachine/area/json")
    public @ResponseBody HttpResult getAutoAreaReportJson(ConsoleContext consoleContext,String startDate,String endDate) {
        AreaReportResp areaReportResp = reportService.getAreaReportRespAuto(startDate, endDate, consoleContext.getFarms());
        return HttpResultUtil.buildSuccess(areaReportResp);
    }

    @RequestMapping("/console/report/automachine/json")
    public @ResponseBody HttpResult activeMachineJson(ConsoleContext consoleContext,String startDate,String endDate){
        AreaReportResp areaReportResp = reportService.getActiveRespAuto(startDate, endDate, consoleContext.getFarms());
        return HttpResultUtil.buildSuccess(areaReportResp);
    }

}
